<?php
// 获得超时预约信息
// header("content-type:text/html;charset=UTF-8");
include_once("conn.php");

$uid = $_GET['uid'];

//设置中国时区
date_default_timezone_set('Asia/Shanghai');
// 获取当前日期
$nowDate = date('Y-m-d');
$nowTime = date('H:i:s');
$select_die_order = "SELECT * FROM order_infos LEFT JOIN department_infos ON order_infos.orderType = department_infos.department_ID WHERE user_ID = '" . $uid . "' AND orderDate < '" . $nowDate . "'";
$result_die_order = mysqli_query($connect_DB, $select_die_order);
if ($result_die_order) {
    if (mysqli_num_rows($result_die_order) > 0) {
        while ($row_die_order = mysqli_fetch_object($result_die_order)) {
            if($row_die_order->orderState == '1'){
                $state = '超时未处理';
            }else{
                $state = '取消未受理';
            }
            $select_doc = "SELECT * FROM doc_infos WHERE doc_ID = '" . $row_die_order->doc_ID . "'";
            $result_doc = mysqli_query($connect_DB, $select_doc);

            $select_user = "SELECT * FROM user_infos WHERE user_ID = '" . $row_die_order->user_ID . "'";
            $result_user = mysqli_query($connect_DB, $select_user);

            $select_pet = "SELECT * FROM pet_infos WHERE pet_ID = '" . $row_die_order->pet_ID . "'";
            $result_pet = mysqli_query($connect_DB, $select_pet);

            if ($result_user && $result_pet && $result_doc) {
                $row_user = mysqli_fetch_object($result_user);
                $row_pet = mysqli_fetch_object($result_pet);
                $row_doc = mysqli_fetch_object($result_doc);
                echo"
                <div class='con-lists'>
                    <div class='orderid'>".$row_die_order->orderID."</div>
                    <div class='username'>".$row_user->user_Name."</div>
                    <div class='petname'>".$row_pet->pet_Name."</div>
                    <div class='orderdate'>".$row_die_order->orderDate." ".$row_die_order->orderTime."</div>
                    <div class='orderdoc'>".$row_doc->doc_Name."</div>
                    <div class='ordertype'>".$row_die_order->department_Name."</div>
                    <div class='orderstatus'>".$state."</div>
                    <div class='caozuo'><a href='a_DelDieOrder.php?orderid=".$row_die_order->orderID."'>删除该信息</a></div>
                </div>
                ";
            } else {
                echo "<div class='con-lists'><div class='orderstatus'>查询相关信息出错</div></div>";
            }
        }
    }else{
        echo "<div class='con-lists'><div class='orderstatus'>暂无信息</div></div>";
    }
} else {
    echo "<div class='con-lists'><div class='orderstatus'>查询超时预约信息出错！</div></div>";
}

$connect_DB->close();
?>